//
//  JWGRRefuseLookVC.m
//  test
//
//  Created by 李彦宏 on 2018/3/13.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "JWGRRefuseLookVC.h"
#import "JWUserManager.h"
#import "JWGRUsermodel.h"
#import "JWGROtherFeemodel.h"
@interface JWGRRefuseLookVC ()<UITextViewDelegate,UITextFieldDelegate>
@property (nonatomic, strong) JWGRUsermodel *Gmodel;
@property (nonatomic, strong) JWGROtherFeemodel *model;

@property (weak, nonatomic) IBOutlet UIButton *SubmitBtn;//提交按钮
@property (weak, nonatomic) IBOutlet UITextView *FeeDescTeXView;//费用描述
@property (weak, nonatomic) IBOutlet UITextField *FeeSumNB;//费用合计

@end

@implementation JWGRRefuseLookVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.Gmodel=[JWUserManager Gme];
    self.model=self.arry[0];
    self.title=@"费用详情";
    [self setTextview];
    self.FeeSumNB.text=self.model.money;
}
-(void)setTextview{
    // 设置代理
    self.FeeDescTeXView.delegate = self;
    self.FeeDescTeXView.text=self.model.discrabe;
    // 设置文本字体
    self.FeeDescTeXView.font = [UIFont fontWithName:@"Arial" size:15];
    self.FeeDescTeXView.textColor=[UIColor blackColor];
    // 设置文本对齐方式
    self.FeeDescTeXView.textAlignment = NSTextAlignmentLeft;
    //自动纠错
    self.FeeDescTeXView.autocorrectionType=UITextAutocorrectionTypeNo;
    //外框
    self.FeeDescTeXView.layer.borderColor=dominantColor.CGColor;
    self.FeeDescTeXView.layer.borderWidth=1;
    self.FeeDescTeXView.layer.cornerRadius=5;
    //不自动大小写
    self.FeeDescTeXView.autocapitalizationType=UITextAutocorrectionTypeNo;
    // 设置return键样式
    self.FeeDescTeXView.returnKeyType = UIReturnKeyDefault;
    // 设置是否可以拖动
    self.FeeDescTeXView.scrollEnabled = NO;
    
}


-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    if (textField == self.FeeSumNB){
        NSUInteger lengthOfString = string.length;
        for (NSInteger loopIndex = 0; loopIndex < lengthOfString; loopIndex++) {//只允许数字输入
            unichar character = [string characterAtIndex:loopIndex];
            if (character < 48) return NO; // 48 unichar for 0
            if (character > 57) return NO; // 57 unichar for 9
        }
        // Check for total length
        NSUInteger proposedNewLength = textField.text.length - range.length + string.length;
        if (proposedNewLength > 11) return NO;//限制长度
        return YES;
    }else{
        NSUInteger proposedNewLength = textField.text.length - range.length + string.length;
        if ( proposedNewLength > 20) return NO;//限制长度
        return YES;
    }
}
- (IBAction)SubmitAction:(id)sender {
    NSDictionary *dict=@{
                         @"jwid" : JWid,
                         @"jwpassword" : JWpassword,
                         @"cid":self.model.ID,
                 @"discrabe":self.FeeDescTeXView.text,
                         @"money":self.FeeSumNB.text,
                         };
    [[AFNetworkTool shareManager]postJSONWithUrl:JWteacher_GROtUpRefused parmas:dict successData:^(id json) {
      //  NSLog(@"--json--%@", json);
        
        [MBProgressHUD showSuccess:@"提交成功！"];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.navigationController popViewControllerAnimated:YES];
        });
        
    } failure:^(NSError *error) {
        NSLog(@"--error--%@", error);
        [MBProgressHUD showError:@"提交失败！"];
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
